package com.iris.nio;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.AsynchronousServerSocketChannel;
import java.util.concurrent.ExecutionException;

public class AioHandlerServer {
    public static void main(String[] args) throws IOException, ExecutionException, InterruptedException {
        AsynchronousServerSocketChannel serverChannel = AsynchronousServerSocketChannel.open();
        serverChannel.bind(new InetSocketAddress(8888));
        AioAttach aioAttach = new AioAttach();
        aioAttach.setId("id");
        aioAttach.setName("name");
        AioAcceptHandler handler = new AioAcceptHandler();
        serverChannel.accept(aioAttach,handler);
        while(true){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
